package programDetails;

import java.util.Stack;

/**
 * @Description: 栈的相关方法
 * @Date: 2020/4/14
 * @Author: 许群星
 */
public class _2_2_MethodOfStack {
    public static void main(String[] args) {
        Stack<Integer> stack=new Stack<>();

        //入栈 push
        stack.push(1);
        stack.push(2);

        //得到栈顶元素 pop
        System.out.println(stack.peek());
        stack.push(3);
        System.out.println(stack.peek());

        //出栈    pop
        int a=stack.pop();
        System.out.println(a);
        System.out.println(stack.peek());

        //判断是否为空
        System.out.println(stack.isEmpty());//集合类的方法，具体实现是一样的
        System.out.println(stack.empty());


    }
}
